<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <link rel="stylesheet" href="/plugins/layui/css/layui.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="../plugins/layui/css/style.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/theme.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/add.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/sm.css?v=${.Config.basic.version}" media="all">
    <link rel="stylesheet" href="/plugins/layui/css/table.css?v=${.Config.basic.version}" media="all">
    <style>
        .layui-form-item .layui-inline {
            margin-bottom: 0;
            margin-right: 0;
        }
        .layui-select-title > input {
            width:100px;
            height:25px;
            line-height:1;
            border-width:1px;
            border-style:solid;
            background-color:#fff;
            border-radius:2px;
            border-color:#e6e6e6;
            padding-left: 5px;
        }
    </style>
</head>

<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改密码</div>
                <div class="layui-card-body" pad15>

                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="old_pwd" lay-verify="required" lay-verType="tips" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="new_pwd" lay-verify="required" lay-verType="tips" autocomplete="off" id="LAY_password" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">为了安全，建议不要使用太简单的密码</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="new_pwd1" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn layui-btn-normal action-edit" lay-submit lay-filter="btn_ok">保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>


<script src="/plugins/layui/layui.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/func.js"></script>
<script>
    var net_ip = GetQueryString('net_ip');
    var slot_index = GetQueryString('slot_index');
    var level = GetQueryString('level');

    var table=null;
    var form=null;
    var laydate=null;
    var iconPicker =null;
    var Table=null;
    var sys_roles=null;
    var token = window.localStorage.getItem("token");
    var user_info=JSON.parse(window.localStorage.getItem("user_info"));
    var func_url="${.func_url}";
    var actions=[];
    var permissions=[];
    token = 'Bearer ' + token;

    layui.config({
        base: '../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','form','laydate'], function(){
        $ = layui.$;
        form = layui.form;
        table = layui.table;
        layui.form.render();

        layer.load(1);
        $.ajax({
            type: 'GET',
            url: '../Api/User',
            data: {},
            beforeSend: function(request) {
                request.setRequestHeader("Authorization", 'Bearer '+window.localStorage.getItem("token"));
            },
            dataType: "json",
            success: function (data) {
                layer.closeAll();
                console.info(data);
                form.val("form", data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.msg('加载用户信息失败');
            }
        });

        //监听提交
        form.on('submit(btn_ok)', function(data){
            var field = data.field; //获取提交的字段

            if(field.new_pwd!==field.new_pwd1){
                layer.alert("两次输入的新密码不一致");
                return;
            }

            $.ajax({
                type: 'PUT',
                url: '../Api/User/Pwd',
                data: field,
                beforeSend: function(request) {
                    request.setRequestHeader("Authorization", 'Bearer ' + window.localStorage.getItem("token"));
                },
                dataType: "json",
                success: function (data) {
                    //console.info(data)
                    if(data.code>=0){
                        layer.msg('保存成功');
                    }else{
                        layer.alert('保存失败:'+data.msg);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert('保存失败');
                }
            });

        });
    });



</script>

<script src="../js/check_screen.js?v=${.Config.basic.version}"></script>

</body>

</html>